//
//  WBNetAPIBusiness.m
//  WeiBo
//
//  Created by wbs on 17/2/10.
//  Copyright © 2017年 xiaomaolv. All rights reserved.
//

#import "WBNetAPIBusiness.h"

#import "WBNetAPIManager.h" 
#import "WBHomeStatusesParamter.h"
#import "WBHomeStatusesResult.h"
#import "WBUserContentParamter.h"
#import "WBUserContentResult.h"
#import "WBMyFunsParameter.h"
#import "WBMyFunsResult.h"
#import "WBSendStatusParameter.h"
#import "WBSendStatusResult.h"
#import "WBStatusCommentsParameter.h"
#import "WBStatusCommentsResult.h"

@implementation WBNetAPIBusiness

/// 0000
+ (NSURLSessionTask *)currentUserContent:(WBUserContentParamter *)paramter completion:(void (^)(WBUserContentResult *, NSError *))completion
{
    NSMutableDictionary *param = [paramter mj_keyValues];
    return [WBNetAPIManager requestWithURL:kCurrentUserContentUrlString parameters:param method:WBNetMethod_GET completion:^(id responseObjects, NSError *error) {
        if (error) {
            if (completion) {
                completion(nil, error);
            }
        } else {
            if (completion) {
                WBUserContentResult *result = [WBUserContentResult mj_objectWithKeyValues:responseObjects];
                completion(result, nil);
            }
        }
    }];
    
}

/// 0001
+ (NSURLSessionTask *)homeStatuses:(WBHomeStatusesParamter *)paramter completion:(void (^)(WBHomeStatusesResult *, NSError *))completion
{
    NSMutableDictionary *param = [paramter mj_keyValues];
    return [WBNetAPIManager requestWithURL:kCurrentUserWeiBoUrlString parameters:param method:WBNetMethod_GET completion:^(id responseObjects, NSError *error) {
        if (error) {
            if (completion) {
                completion(nil, error);
            }
        } else {
            if (completion) {
                WBHomeStatusesResult *result = [WBHomeStatusesResult mj_objectWithKeyValues:responseObjects];
                completion(result, nil);
            }
        }
    }];
}

/// 0002
+ (NSURLSessionTask *)myFuns:(WBMyFunsParameter *)paramter completion:(void (^)(WBMyFunsResult *, NSError *))completion
{
    NSMutableDictionary *param = [paramter mj_keyValues];
    return [WBNetAPIManager requestWithURL:kMyFunsUrlString parameters:param method:WBNetMethod_GET completion:^(id responseObjects, NSError *error) {
        if (error) {
            if (completion) {
                completion(nil, error);
            }
        } else {
            if (completion) {
                WBMyFunsResult *result = [WBMyFunsResult mj_objectWithKeyValues:responseObjects];
                completion(result, nil);
            }
        }
    }];
}

/// 0003
+ (NSURLSessionTask *)sendStatus:(WBSendStatusParameter *)paramter completion:(void (^)(WBSendStatusResult *, NSError *))completion
{
    NSMutableDictionary *param = [paramter mj_keyValues];
    return [WBNetAPIManager requestWithURL:kSendStatusUrlString parameters:param method:WBNetMethod_POST completion:^(id responseObjects, NSError *error) {
        if (error) {
            if (completion) {
                completion(nil, error);
            }
        } else {
            if (completion) {
                WBSendStatusResult *result = [WBSendStatusResult mj_objectWithKeyValues:responseObjects];
                completion(result, nil);
            }
        }
    }];
}

/// 0004
+ (NSURLSessionTask *)statusComments:(WBStatusCommentsParameter *)paramter completion:(void (^)(WBStatusCommentsResult *, NSError *))completion
{
    NSMutableDictionary *param = [paramter mj_keyValues];
    return [WBNetAPIManager requestWithURL:kStatusCommentsString parameters:param method:WBNetMethod_GET completion:^(id responseObjects, NSError *error) {
        if (error) {
            if (completion) {
                completion(nil, error);
            }
        } else {
            if (completion) {
                WBStatusCommentsResult *result = [WBStatusCommentsResult mj_objectWithKeyValues:responseObjects];
                completion(result, nil);
            }
        }
    }];
}

@end
